<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>文件上传</title>
</head>
<body>
	
	<div class="file-container">
		<form action="">
			<input type="file" name="fileContent" id="file-input">
		</form>
	</div>

	<script>

		let fileInput = document.getElementById('file-input');

		fileInput.onchange = function () {
			console.log('文件名：', this.value);
			let fileReader = new FileReader()
			let fileType = this.files[0].type
			fileReader.onload = function () {
				if (/^image\[jpeg|png|gif]/.test(fileType)) {
					console.log(this.result);
				}
			}
			console.log(this.files[0]);
			fileReader.readAsDataURL(this.files[0])
		}

		console.dir(fileInput);


	</script>
</body>
</html>